using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SpecialAbilityManager {
	
	static string typeName = "SpecialAbility";
	
	static GenericManager<Ability> _m;
	
	static GenericManager<Ability> m
	{
		get
		{
			if(_m == null)
				_m = new GenericManager<Ability>(typeName);
			return _m;
		}
	}
	
	public static Dictionary<string,string> index
	{
		get
		{
			return m.index;
		}
	}
	
	public static Ability Load(string name)
	{
		return m.LoadObject(name);
	}
	
	public static bool isCustom(string name)
	{
		return m.isCustom(name);
	}
		
	public static Ability AddSpecialAbility( string name, string description, bool iterative, 
										bool replacementAbility, List<string> replacementList, 
										List<string> buffsList = null)
	{
		Ability a = new Ability();
		a.name = name;
		a.description = description;
		a.iterative = iterative;
		a.replacementAbility = false;
		
		if(a.iterative)
		{
			a.iterativeName = a.name;
			a.name = a.getIteratedName(null);
		}
		
		a.buffs = new List<BuffDebuff>();
		if(buffsList != null)
			buffsList.ForEach(bn =>
			{
				a.buffs.Add(BuffDebuffManager.Load(bn));
			});
		
		return m.AddObject(a);
	}
	
	public static bool SaveAbility(Ability a, string file)
	{
		if(a.iterative)
		{
			a.iterativeName = a.name;
			a.name = a.getIteratedName(null);
		}
		
		return m.SaveObject(a, file);
	}
	
	public static void DeleteAbility(string name)
	{
		m.DeleteObject(name);
	}
}
